package com.fqgj.sentry.policy.engine.exception;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fqgj.sentry.policy.engine.resolver.CheckParser;

public class ParserException extends RuntimeException{


    private static ObjectMapper mapper = CheckParser.getJsonMapper();


    public ParserException() {
        super();
    }


    public ParserException(String message) {
        super(message);
    }


    public ParserException(String message, Throwable cause) {
        super(message, cause);
    }


    /**
     * 出错对象信息
     */
    private Object errorObj;

    public String getErrorObj() {

        String obj = null;
        try {
            obj = mapper.writeValueAsString(errorObj);
        } catch (JsonProcessingException e) {
            e.printStackTrace();
        }
        return obj;
    }

    public ParserException setErrorObj(Object errorObj) {
        this.errorObj = errorObj;
        return this;
    }
}
